﻿using MaterialSkin.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TomatoClock.Views
{
    public partial class CustomTimeDialog : MaterialForm
    {
        public int CustomTime { get; private set; }

        public CustomTimeDialog()
        {
            InitializeComponent();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            if (int.TryParse(customTimeTextBox.Text, out int time) && time > 0)
            {
                CustomTime = time;
                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("请输入有效的整数");
            }
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void CustomTimeDialog_Load(object sender, EventArgs e)
        {
            customTimeTextBox.Text = "请输入分钟数";
            customTimeTextBox.ForeColor = Color.Gray; // 可选：设置水印文本的颜色
        }

        private void customTimeTextBox_Click(object sender, EventArgs e)
        {

        }

        private void customTimeTextBox_Enter(object sender, EventArgs e)
        {
            if (customTimeTextBox.Text == "请输入分钟数")
            {
                customTimeTextBox.Text = "";
                customTimeTextBox.ForeColor = SystemColors.ControlText; // 恢复为默认文本颜色
            }
        }

        private void customTimeTextBox_Leave(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(customTimeTextBox.Text))
            {
                customTimeTextBox.Text = "请输入分钟数";
                customTimeTextBox.ForeColor = Color.Gray; // 恢复为水印文本颜色
            }
        }
    }
}
